Control strategies for inverted pendulum: A comparative analysis of linear, nonlinear, and artificial intelligence approaches

An inverted pendulum is a challenging underactuated system characterized by nonlinear behavior. Defining an effective control strategy for such a system is challenging. This paper presents an overview of the IP control system augmented by a comparative analysis of multiple control strategies. Linear techniques such as linear quadratic regulators (LQR) and progressing to nonlinear methods such as Sliding Mode Control (SMC) and back-stepping (BS), as well as artificial intelligence (AI) methods such as Fuzzy Logic Controllers (FLC) and SMC based Neural Networks (SMCNN). These strategies are studied and analyzed based on multiple parameters. Nonlinear techniques and AI-based approaches play key roles in mitigating IP nonlinearity and stabilizing its unbalanced form. The aforementioned algorithms are simulated and compared by conducting a comprehensive literature study. The results demonstrate that the SMCNN controller outperforms the LQR, SMC, FLC, and BS in terms of settling time, overshoot, and steady-state error. Furthermore, SMCNN exhibit superior performance for IP systems, albeit with a complexity trade-off compared to other techniques. This comparative analysis sheds light on the complexity involved in controlling the IP while also providing insights into the optimal performance achieved by the SMCNN controller and the potential of neural network for inverted pendulum stabilization.


Introduction
The design of a control system for an inverted pendulum (IP) is a classical problem employed in nonlinear control systems.IP has many practical applications in various fields, such as humanoid robots and Segways.IP is a highly unstable and nonlinear system with a very complex nature.As an under-actuated system, the control design of an IP is considered a challenging task.
Several types of inverted pendulums, such as rotational IP and pendulum on the cart, have been previously tested, and researchers have proposed various methods to control these IP systems.The authors of [1][2][3] proposed a backstepping (BS)-based control technique for IP control.They proposed that the BS controls a two-step approach where swing up, while upward balancing is attained by a linear integral regulator.Lee et al. (2015) proposed an output feedback-based technique in the existence of uncertainties to stabilize IP on a cart [4].A highgain observer is used to estimate the states that are not measured in order to combat their uncertain nature.Lee and Takangi (1993) proposed an optimized genetic algorithm through a fuzzy controller to control the IP [5].The genetic algorithm methodologies in control system engineering have been applied to several problems.Cuevas et al. (2015) proposed a fuzzy logic-based optimal controller for IP, in which the results for both the phase plan and linguistic trajectories are presented, and they demonstrated stable characteristics [6].Optimal PID control for the linear model of IP is combined with pole placement algorithms to obtain the performance specifications, which leads to firefly optimization control [7].Similarly, Eltohamy and Kuo (1998) designed a nonlinear controller for a single IP, based on an unstable upright position.An extended state observer is designed to observe the disturbances and uncertainties that have a rejection ability [8].The researcher in [9] experimented with a traditional fuzzy controller to stabilize a single IP and improve the dynamics of the system accordingly.
Linear Quadratic Regulator (LQR) is a classical linear control system that can control those systems where disturbances and uncertainties are absent.This technique allows one to find the closed-loop gain location for the system by guaranteeing system stability in the presence of all states of the system [10,11].Sliding Mode Control (SMC) is a robust control technique that deals with the parametric uncertainties of matched and unmatched disturbances [12][13][14].More consistency is required between the mathematical and actual models of the system.To overcome these discrepancies, robust control techniques such as SMC are more effective [15].Fuzzy Logic Controller (FLC) is an artificial intelligence (AI) control technique that is used to develop a model for a complex system.This simplifies the model under certain assumptions and reduces the complexity of the system.It maintains the system's energy in a steady state (up down position) [16,17].Similarly, a Neural Network (NN) is a practical algorithm for modeling nonlinear statistical scenarios by providing a method for logistic regression.It estimates the function, which has multiple inputs initially considered as unknown, and interconnects the system that exchanges information with each other [18].NN connections have a numerical weight matrix, and based on previous information, NNs adapt to the input to achieve better learning capabilities [19][20][21].
This research study explores linear, nonlinear, and AI control strategies, such as LQR, SMC, BS, FLC, and SMCNN, and a comparative analysis is augmented with simulations of the selected algorithms.An IP without a controller is inherently unstable.Hence, to check and maintain its stability, we must manipulate it to check the response of the system vertically and horizontally.The FLC technique provides a benchmark for testing IP response without a mathematical approach.It stabilizes the system and maintains the cart in the desired position.The SMC is designed and implemented to check the response of the nonlinear and underactuated systems.It has a single input and two outputs for the cart position and pendulum angle.Therefore, this technique stabilizes the uncertain SIMO and MIMO systems.The LQR controller, which is an optimal control technique for the desired trajectories, is also simulated.The BS and SMCNN are explored in terms of IP stability to observe the behavior of the system.The FLC, SMC, and LQR simulation results are compared to analyze the behavior of the linear and nonlinear families on the control strategies.
The remainder of this paper is organized as follows.Section 1 describes the details of IP modeling, including linear and nonlinear models, while Section 2 presents different control approaches to stabilize the IP.Section 3 presents the results of the implemented control techniques, and Section 4 concludes the overall analysis of our research.

Modeling of inverted pendulum
The physical system of an IP is depicted in Fig 1 , and comprises an IP mounted on a cart moving on a rail.The translational movement of the cart is enabled by DC motors that swing freely in a vertical position.A motor shaft is connected to the cart using thin steel wire.The IP system model is divided into two parts.The first is the mechanical structure of the cart and pendulum angle and the second is the DC motor transmission model.
The mathematical model of the IP is formulated using a Newtonian approach.The movement of the cart is due to horizontally applied forces, as it is not affected by vertical forces, and it receives the input through an actuator (DC motor) [22].A nonlinear mathematical model of an IP is formulated using a Newtonian approach.The following equations describe the nonlinear mathematical model of an inverted pendulum.
Where M represents the cart mass, m is the mass of the Pendulum, L represents the cart length, l is the length of the pendulum, B is the coefficient of friction of the cart, I is the moment of inertia, T is the torque in the form of external input force which moves cart in the horizontal plane, x is the cart position while € x is the cart acceleration, θ is the angular position of the pendulum and € y is representing the angular acceleration.Eqs (1) and ( 2) are nonlinear and have been linearized to implement a linear controller.As θ is very small, it leads to the fact that the square of the derivative of θ is assumed to be zero.Hence, θ 2 = 0, and the linearized mathematical model of the system can be expressed as follows:

Control techniques
This section describes the implemented control techniques for IP.There are three categories of control techniques for IP, that is, linear, nonlinear, and AI control approaches, and some selected algorithms of each type are shown in Fig 2 .LQR is briefly described as a linear control plan for IP, whereas SMC and BS are presented in the domain of nonlinear algorithms.Finally, AI control techniques such as FLC and SMCNN are explored.

Linear quadratic regulator
The LQR is an optimal linear control technique that can be effectively used to improve the overall performance of a linear system.In general, it is appropriate for linear systems where disturbances and uncertainties are not present [23].The main objective of using the LQR is to estimate the gain that minimizes the cost function [24].A quadratic function-based cost function is used, which is usually defined as: where u and x are the inputs and states of the system, respectively.Similarly, R and Q are the positive definite matrices, where Q(t) 2 R n×n is a positive definite or positive semi-definite Hermitian matrix and R(t) 2 R r×r is a positive definite Hermitian matrix (or real constant number).The gain of the LQR is calculated using the following equation: The following equation gives the Riccati equation for finding the gain of the system Similarly, the generalized illustration of a linear control system is given by Whereas the control law for such a linear system is defined as To compute the gains of the system, the system's open loop response is incorporated and given by _ xðtÞ ¼ AxðtÞ À BKxðtÞ ¼ ðA À BKÞxðtÞ ð10Þ

Sliding mode control
SMC is a robust control technique capable of handling systems with multiple inputs and outputs (MIMO).However, there is always a need for more consistency between the actual model and the mathematical model of the plant when designing the controller [25].Matched and unmatched uncertainties, external disturbances, and parametric uncertainties are the main inconsistencies between the actual and mathematical models of the plant.A robust controller is required to reduce these fundamental factors.SMC ensures global stability and effectively handles the fast dynamic response of a system [26].A block diagram of the overall design is shown in Fig 3. SMC consists of two phases: sliding and reaching.In the reaching phase, the system moves from its initial stage to the final desired trajectories, whereas in the sliding phase, the system remains there at all times.We have two parts of the SMC controller: an equivalent controller and a discontinuous controller.An equivalent controller is designed for the reaching phase, whereas a discontinuous controller is suitable for the sliding surface.The addition of these two controllers resulted in an overall controller for the system.The reaching and sliding phases are illustrated in Fig 4 .3.2.1 Control design with SMC.The control design of the SMC involves the following steps.First, the sliding surface is defined by the following equation Where, e is the error signal and λ is the positive constant Then, by differentiating the sliding surface with respect to time and forcing the time derivative at ðsÞ ¼ _ 0, we get the equivalent controller part of SMC as While the discontinuous controller is designed by using a pre-defined sign function given by The overall controller is obtained through the addition of equivalent and discontinuous parts given as Owing to these huge benefits, the first-order SMC suffers from the chattering phenomenon due to oscillation from the frequency turbulence.Higher-order Sliding Mode Control (HOSMC) is proposed to reduce the chattering effect [27].The Lyapunov stability theorem is used to ensure the stability of the IP system.It is defined as follows, By substituting the time derivative of Eq (17) into the above equation, the derivative of the Lyapunov function _ V is obtained: _ V becomes negative definite and the system dynamics converge to its origin in finite time.

Back-stepping control
The BS is a robust control technique that is highly nonlinear and based on the Lyapunov stability theorem.Stability is achieved through the recursive process, as Lyapunov is a scalar function that ensures the stability of the system [28].This technique can only be implemented by using strict feedback systems.Because the IP is an underactuated system, rather than a pure feedback system, we cannot apply back-stepping directly to the IP.After transformation into the feedback linearizable form, we can apply the BS to the IP control problem.The IP swung initially and stabilized the upright position.The swung-up is obtained through a nonlinear controller, whereas the linear control stabilizes its dynamics.Linearized control techniques stabilize the angle and cart position using transformed regulated variables [29].

Control design with BS.
The control design of the BS method has a Lyapunov Function (LF), and a virtual signal is constructed to stabilize the subsystem until the signal enters system dynamics.Let the first tracking error for the cart position and pendulum's angular position (θ = x 3 ) be given as where x 1d is the desired trajectory of the cart position and x 3d is the desired trajectory of the pendulum's angular position.The stabilizing functions (α 1 , α 2 ) are defined as follows.
Lyapunov candidate functions are defined in terms of the four regulatory variables e 1 , e 2 , e 3 and e 2 as follows Considering the transformed regular form of the cart-pendulum system [30], virtual control input tan(x 3 ) and system control input u are chosen to stabilize x 1 and x 3 , respectively.
The virtual control input tanx 3 and system control input

Fuzzy-logic controller
FLC is a model-less control technique that is suitable for systems with nonlinearities and disturbances [31].This is an AI control technique that stabilizes the behavior of nonlinear systems.FLC is a challenging task, especially when using the IF-Then rule.This will work like human intelligence, and the accuracy of the control action will also increase [32].FLC is an effective technique that systematically controls an uncertain system such as IP [33].
Fig 5 shows an FLC block diagram in which the fuzzy interference process defines the logic to control the DC motor of the IP system through a DAC and amplifier.The microcontroller performs control actions.It samples the input data from the sensors and then controls the speed of the DC motor.The DC motor moves the cart position and balances IP [34].A control design using a fuzzy logic technique is required to obtain the accuracy and stability of the system.The fuzzy interference rules for IP are mainly derived through Mamdani [35] and Sugeno techniques [36].The basic steps of a fuzzy logic control design are the following: 1. Define fuzzy interface process 2. Define the input, output, and membership function

Use the IF-Then rule
There are four inputs and two outputs of the fuzzy controller for the IP.Two membership functions are assigned to each input variable.The Sugeno systems contain 16 output variables.We have 16 Sugeno IF-Then rules for IP.A few important rules are given below:

SMC-based neural network
The SMCNN is a nonlinear control technique.Owing to its lack of stability and nonlinearity, it provides a path for testing the prototype controller.Therefore, different researchers have designed NN-based controllers to test IP [37,38].A supervised NN reduces errors more efficiently and keeps the system stable [39,40].The RBF does not require mathematical modeling and can identify nonlinear and complex systems.A SMCNN can successfully track both IP axes more accurately and effectively [20,41].The Gyroscopic Inverted Pendulum (GIP), which is both nonlinear and unstable in an open loop, is evaluated on a single-layered NN with a nonlinear autoregressive moving average property [21].

Control design. Fig 6 shows
the overall closed-loop control system structure comprising an RBF NN, which estimates F(x) and the controller realized by an optimizer.To approximate the uncertain F, RBF networks are used adaptively.The algorithm of RBF networks is given by where x represents the network's input state, i counts the input number of the network, j is the number of hidden layer nodes in the network, while p = [p 1 p 2 p 3 . . .p n ] T is the yield of Gaussian function, Q is a vector of weights of the specified NN, r is approximation error of NN, and r � r N .RBF network approximation f is used.The network input is chosen as x ¼ ½e _ e� T , and the output of RBF neural network is where p(x) is the NN's Gaussian function in general and the Gaussian function parameters and neural network weights are difficult to choose.For this purpose, an error signal is defined as A sliding manifold is given by Differentiating (35), The control input is as follows Substituting Eqs (37) in (36), we have where, where, Defining the Lyapunov function as where γ is the positive coefficient of the above equation.By taking the derivative of V, we get Substituting the right-hand side of _ s and _ Q, The adaptive control law is designed as follows We obtain approximately _ V ðs; QÞ � 0 because the approximation error r is sufficiently small in design k � r N + D. We obtain approximately _ V ðs; QÞ � 0 because the approximation error r is sufficiently small in design k � r N + D. Table 1 presents a review of different properties of the studied algorithms for IP.Linear techniques such as LQR are simple to implement with less computational complexity than nonlinear techniques such as Artificial and non-artificial based control design.However nonlinear techniques show better transient and steady state performance.

Results and discussion
In this section, we delve into the assessment and comparison of control algorithms, focusing on selecting a representative algorithm from each of the three categories.These selections are made based on the criteria of low complexity and reasonable accuracy when compared to other strategies within their respective classes.Our analysis encompasses key performance parameters such as settling time, rise time, steady-state percentage error, and percentage overshoot.The results for each parameter are presented in a step-wise manner below.
First, Figs 7 and 8 scrutinize the outcomes obtained from all controllers concerning the cart's position and the pendulum's angle.The findings indicate that the system achieves stability in both the cart's position and pendulum's angle after the settling time.Notably, given the inverted pendulum's non-minimum phase nature, the cart initially moved in the opposite direction before successfully tracking the desired position.To provide a comprehensive view of performance, Table 2 details the efficacy of simulated control techniques across all algorithms.Turning our attention to Figs 7 and 8, we examine the response of the cart position and pendulum angle to a step input.Remarkably, all control algorithms effectively restored equilibrium in the cart position and pendulum, achieving upright stability after specific settling times.For instance, the SMCNN control technique emerges as particularly efficient, stabilizing the cart position in a mere 1.5 seconds, outperforming the other strategies in this regard.Similarly, the pendulum angle swiftly converges to its desired trajectory when the SMCNN control technique is applied.Figs 9 and 10 provide further insights into the control  present the simulation results for the control input and error signals across all the simulated methods.Notably, the tracking error approached zero, demonstrating the effectiveness and robustness of the control strategies against both matched and unmatched uncertainties.Additionally, the chattering effect, particularly visible in the SMC case, is notably reduced when employing the BS and SMCNN techniques.A comprehensive overview of the controller performance can be found in Table 2.
In summary, the results obtained from these simulations indicate that all selected control algorithms exhibit stability and promising performance in achieving the desired system design goals.

Conclusions
In this research, we have demonstrated the implementation of a diverse range of control techniques, encompassing linear, nonlinear, and artificial intelligence-based approaches, to tackle real-time challenges.Our primary focus is on the inverted pendulum, which serves as a representative example of a nonlinear, underactuated mechanical system.The versatility of the IP concept extends to various cutting-edge applications, including space satellite control, aircraft landing systems, humanoid robot stability, seismometer control, and the balancing of ships against tides.Throughout this study, we have effectively harnessed robust control techniques to ensure stability and precise response in nonlinear systems, particularly emphasizing the  Recognizing the importance of more extensive statistical analysis for a comprehensive evaluation of control strategies, future endeavors will involve the incorporation of more in-depth

Fig 4 .
Fig 4. Block phases of SMC.https://doi.org/10.1371/journal.pone.0298093.g004 1. (Position is PL) and (Velocity is VL) and (angle is AL) and (angular velocity is AVL) then (Force is FLM), 2. (Position is PL) and (Velocity is VL) and (angle is AL) and (angular velocity is AVL) then (Force is FL), 3. (Position is PL) and (Velocity is VL) and (angle is AL) and (angular velocity is AVL) then (Force is zero), 4. (Position is PH) and (Velocity is VL) and (angle is AL) and (angular velocity is AVH) then (Force is zero), 5. (Position is PH) and (Velocity is VL) and (angle is AL) and (angular velocity is AVH) then (Force is TR), 6. (Position is PH) and, (Velocity is VL) and, (angle is AL), and (angular velocity is AVH), then (Force is TRM).